<template>
    <div>
        <Row class="formRow">
          <Col span="2" class="rightRow">
            <span class="ModelInputTitle">项目编码</span>
          </Col>
          <Col span="2" class="leftRow">
            <Input v-model="formInline.projectCode" placeholder="项目编码" clearable style="width: 100%" size="large"></Input>
          </Col>
          <Col span="2" class="rightRow">
            <span class="ModelInputTitle">中文名称</span>
          </Col>
          <Col span="2" class="leftRow">
            <Input v-model="formInline.chinaName" placeholder="中文名称" clearable style="width: 100%" size="large"></Input>
          </Col>
          <Col span="2" class="rightRow">
            <span class="ModelInputTitle">是否组套</span>
          </Col>
          <Col span="2" class="leftRow">
            <Select  size="large" style="width:100%" v-model="formInline.stackFlag">
              <Option  value="1" >组套</Option>
              <Option  value="0" >未组套</Option>
            </Select>
          </Col>
          <Col span="2" class="rightRow">
          <span class="ModelInputTitle">是否启用</span>
          </Col>
          <Col span="2" class="leftRow">
            <Select  size="large" style="width:100%" v-model="formInline.availableFlag">
              <Option  value="1" >启用</Option>
              <Option  value="0" >不启用</Option>
            </Select>
          </Col>
          <Col span="8" class="leftRow">
            <Button type="primary" @click="onSubmit">查询</Button>
            <Button type="primary" @click="resetForm">重置</Button>
            <Button type="primary" @click="onAdd">添加</Button>
          </Col>
        </Row>


      <Table :data="tableData" :columns="cloums" stripe :loading="loading"  style="margin-top: 20px"></Table>
      <div style="margin: 10px;overflow: hidden">
        <div style="float: right;">
          <Page :total="total" :placement="placement" :current="1" @on-change="changePage" show-total show-elevator show-sizer @on-page-size-change="changeSize"></Page>
        </div>
      </div>

      <Modal
        v-model="add"
        title="添加项目"
        @on-ok="addok"
        @on-cancel="cancel('您取消了操作')" width="600">
        <Row>
          <Col span="12">   <span class="ModelInputTitle"><Icon type="ios-medical" color="red"></Icon>英文名称</span><Input v-model="addForm.englishName" style="width: 200px"></Input></Col>
          <Col span="12">   <span class="ModelInputTitle"><Icon type="ios-medical" color="red"></Icon>中文名称</span><Input v-model="addForm.chinaName" style="width: 200px"></Input></Col>
        </Row>
        <Row style="margin-top: 20px">
          <Col span="12">   <span class="ModelInputTitle"><Icon type="ios-medical" color="red"></Icon>物价编码</span><Input v-model="addForm.priceCode" style="width: 200px"></Input></Col>
          <Col span="12">   <span class="ModelInputTitle"><Icon type="ios-medical" color="red"></Icon>样品保存条件</span><Input v-model="addForm.specimenSaveDiction" style="width: 200px"></Input></Col>
        </Row>
        <Row style="margin-top: 20px">
          <Col span="12">   <span class="ModelInputTitle">结果类型</span> <Select  size="large" style="width:198px" v-model="addForm.resultType">
          <Option v-for="result in resultTypeArr" :value="result.dataCode" :key="result.id" >{{result.dataName}}</Option>
        </Select></Input></Col>
          <Col span="12">   <span class="ModelInputTitle">是否启用</span> <Select  size="large" style="width:198px" v-model="addForm.availableFlag">
          <Option  value="1" >启用</Option>
          <Option  value="0" >未启用</Option>
        </Select></Input></Col>
        </Row>
        <Row style="margin-top: 20px">
          <Col span="12">   <span class="ModelInputTitle">项目类型</span> <Select  size="large" style="width:198px" v-model="addForm.projectTypeId">
          <Option v-for="p in parProject" :value="p.id" :key="p.id" >{{p.proTypeName}}</Option>
        </Select></Input></Col>
          <Col span="12">   <span class="ModelInputTitle">是否特检</span> <Select  size="large" style="width:198px" v-model="addForm.isSpecial">
          <Option  value="1" >是</Option>
          <Option  value="0" >否</Option>
        </Select></Input></Col>
        </Row>
        <Row style="margin-top: 20px">
          <Col span="12">   <span class="ModelInputTitle">实验方法</span><Input v-model="addForm.experimentalMethod" style="width: 200px"></Input></Col>
          <Col span="12">   <span class="ModelInputTitle">标本基本量</span><Input v-model="addForm.specimenBasicContent" style="width: 200px"></Input></Col>
        </Row>
        <Row style="margin-top: 20px">
          <Col span="12">   <span class="ModelInputTitle">标本复查量</span><Input v-model="addForm.specimenReviewContent" style="width: 200px"></Input></Col>
          <Col span="12">   <span class="ModelInputTitle"><Icon type="ios-medical" color="red"></Icon>标本类型</span> <Select  size="large" style="width:198px" v-model="addForm.specimenType">
          <Option v-for="sp in specimenTypeArr"  :value="sp.dataCode" :key="sp.id">{{sp.dataName}}</Option>
        </Select></Input></Col>
        </Row>
        <Row style="margin-top: 20px">
          <Col span="12">   <span class="ModelInputTitle"><Icon type="ios-medical" color="red"></Icon>检测时间</span><Input v-model="addForm.checkTime" style="width: 200px"></Input></Col>
          <Col span="12">   <span class="ModelInputTitle"><Icon type="ios-medical" color="red"></Icon>折扣价</span><Input v-model="addForm.discountedPrice" style="width: 200px"></Input></Col>
        </Row>
        <Row style="margin-top: 20px">
          <Col span="12">   <span class="ModelInputTitle">市场价</span><Input v-model="addForm.marketPrice" style="width: 200px"></Input></Col>
          <Col span="12">   <span class="ModelInputTitle"><Icon type="ios-medical" color="red"></Icon>价格</span><Input v-model="addForm.price" style="width: 200px"></Input></Col>
        </Row>
        <Row style="margin-top: 20px">
          <Col span="12">   <span class="ModelInputTitle">是否组套</span> <Select  size="large" style="width:198px" v-model="addForm.stackFlag">
          <Option  value="1" >组套</Option>
          <Option  value="0" >未组套</Option>
        </Select>
          </Col>
          <Col span="12">   <span class="ModelInputTitle">样品要求</span><Input v-model="addForm.specimenRequest" style="width: 200px"></Input></Col>
        </Row>
        <Row style="margin-top: 20px">
          <Col span="24">   <span class="ModelInputTitle">备注</span><Input type="textarea" :rows="3" v-model="addForm.remark" style="width: 485px"></Input></Col>
        </Row>
        <Row style="margin-top: 20px">
          <Col span="24">   <span class="ModelInputTitle">医学解释</span><Input type="textarea" :rows="3" v-model="addForm.medicineExplain" style="width: 485px"></Input></Col>
        </Row>
      </Modal>

      <Modal
        v-model="edit"
        title="编辑项目"
        @on-ok="editok"
        @on-cancel="cancel('您取消了操作')" width="600">
        <Row>
          <Col span="12">   <span class="ModelInputTitle"><Icon type="ios-medical" color="red"></Icon>英文名称</span><Input v-model="editForm.englishName" style="width: 200px"></Input></Col>
          <Col span="12">   <span class="ModelInputTitle"><Icon type="ios-medical" color="red"></Icon>中文名称</span><Input v-model="editForm.chinaName" style="width: 200px"></Input></Col>
        </Row>
        <Row style="margin-top: 20px">
          <Col span="12">   <span class="ModelInputTitle"><Icon type="ios-medical" color="red"></Icon>物价编码</span><Input v-model="editForm.priceCode" style="width: 200px"></Input></Col>
          <Col span="12">   <span class="ModelInputTitle"><Icon type="ios-medical" color="red"></Icon>样品保存条件</span><Input v-model="editForm.specimenSaveDiction" style="width: 200px"></Input></Col>
        </Row>
        <Row style="margin-top: 20px">
          <Col span="12">   <span class="ModelInputTitle">结果类型</span> <Select  size="large" style="width:198px" v-model="editForm.resultType">
          <Option v-for="result in resultTypeArr" :value="result.dataCode" :key="result.id" >{{result.dataName}}</Option>
        </Select></Input></Col>
          <Col span="12">   <span class="ModelInputTitle">是否启用</span> <Select  size="large" style="width:198px" v-model="editForm.availableFlag">
          <Option  value="1" >启用</Option>
          <Option  value="0" >未启用</Option>
        </Select></Input></Col>
        </Row>
        <Row style="margin-top: 20px">
          <Col span="12">   <span class="ModelInputTitle">项目类型</span> <Select  size="large" style="width:198px" v-model="editForm.projectTypeId">
          <Option v-for="p in parProject" :value="p.id" :key="p.id" >{{p.proTypeName}}</Option>
        </Select></Input></Col>
          <Col span="12">   <span class="ModelInputTitle">是否特检</span> <Select  size="large" style="width:198px" v-model="editForm.isSpecial">
          <Option  value="1" >是</Option>
          <Option  value="0" >否</Option>
        </Select></Input></Col>
        </Row>
        <Row style="margin-top: 20px">
          <Col span="12">   <span class="ModelInputTitle">实验方法</span><Input v-model="editForm.experimentalMethod" style="width: 200px"></Input></Col>
          <Col span="12">   <span class="ModelInputTitle">标本基本量</span><Input v-model="editForm.specimenBasicContent" style="width: 200px"></Input></Col>
        </Row>
        <Row style="margin-top: 20px">
          <Col span="12">   <span class="ModelInputTitle">标本复查量</span><Input v-model="editForm.specimenReviewContent" style="width: 200px"></Input></Col>
          <Col span="12">   <span class="ModelInputTitle"><Icon type="ios-medical" color="red"></Icon>标本类型</span> <Select  size="large" style="width:198px" v-model="editForm.specimenType">
          <Option v-for="sp in specimenTypeArr"  :value="sp.dataCode" :key="sp.id">{{sp.dataName}}</Option>
        </Select></Input></Col>
        </Row>
        <Row style="margin-top: 20px">
          <Col span="12">   <span class="ModelInputTitle"><Icon type="ios-medical" color="red"></Icon>检测时间</span><Input v-model="editForm.checkTime" style="width: 200px"></Input></Col>
          <Col span="12">   <span class="ModelInputTitle"><Icon type="ios-medical" color="red"></Icon>折扣价</span><Input v-model="editForm.discountedPrice" style="width: 200px"></Input></Col>
        </Row>
        <Row style="margin-top: 20px">
          <Col span="12">   <span class="ModelInputTitle">市场价</span><Input v-model="editForm.marketPrice" style="width: 200px"></Input></Col>
          <Col span="12">   <span class="ModelInputTitle"><Icon type="ios-medical" color="red"></Icon>价格</span><Input v-model="editForm.price" style="width: 200px"></Input></Col>
        </Row>
        <Row style="margin-top: 20px">
          <Col span="12">   <span class="ModelInputTitle">是否组套</span> <Select  size="large" style="width:198px" v-model="editForm.stackFlag">
          <Option  value="1" >组套</Option>
          <Option  value="0" >未组套</Option>
        </Select></Col>
          <Col span="12">   <span class="ModelInputTitle">样品要求</span><Input v-model="editForm.specimenRequest" style="width: 200px"></Input></Col>
        </Row>
        <Row style="margin-top: 20px">
          <Col span="24">   <span class="ModelInputTitle">备注</span><Input type="textarea" :rows="3" v-model="editForm.remark" style="width: 485px"></Input></Col>
        </Row>
        <Row style="margin-top: 20px">
          <Col span="24">   <span class="ModelInputTitle">医学解释</span><Input type="textarea" :rows="3" v-model="editForm.medicineExplain" style="width: 485px"></Input></Col>
        </Row>
      </Modal>

      <Modal
        v-model="project"
        title="配置组套"
        @on-ok="projectok"
        @on-cancel="cancel('您取消了配置组套')" width="600" >
        <Transfer
          :data="projectList"
          :target-keys="projectListSelected"
          filterable
          :filter-method="filterMethod"
          @on-change="handleChange2" :titles="titleProject"></Transfer>
      </Modal>
      <Modal
        v-model="tips"
        title="提示"
        @on-ok="tipsok"
        @on-cancel="cancel('您取消了操作')">
        <p><Icon type="information-circled" color="blue" size="24" style="margin-right: 10px"></Icon>确定给"{{projecName}}"配置组套吗？</p>
      </Modal>
      <Modal
        v-model="detail"
        title="组套详情" width="600">
        <Table :data="detailData" :columns="detailtCloums" stripe :loading="detailLoading"  style="margin-top: 20px"></Table>
        <!--<div style="margin: 10px;overflow: hidden">-->
          <!--<div style="float: right;">-->
            <!--<Page :total="total" :current="1" @on-change="changePage" show-total show-elevator show-sizer @on-page-size-change="changeSize"></Page>-->
          <!--</div>-->
        <!--</div>-->
        <div slot="footer">
        </div>
      </Modal>

    </div>
</template>
<script type="text/ecmascript-6">
  import axios from "axios"
    export default {
      name:"ProjectM",
        data() {
            return {
              formInline:{
                availableFlag:"",//是否启用
                chinaName:"",
                projectCode:"",
                stackFlag:""//是否组套
              },
              add:false,//添加项目
              addForm:{
                englishName:"",
                chinaName:"",
                priceCode:"",//物价编码
                specimenSaveDiction:"",//样本保存条件
                resultType:"",
                availableFlag:"",
                experimentalMethod:"",
                specimenBasicContent:"",
                specimenReviewContent:"",
                specimenType:"",
                checkTime:"",
                discountedPrice:"",
                marketPrice:"",
                price:"",
                medicineExplain:"",
                stackFlag:"",
                isSpecial:"",//是否特检
                projectTypeId:"",//项目类型id
                specimenRequest:"",//样品要求
                remark:""
              },
              edit:false,
              editForm:{
                englishName:"",
                chinaName:"",
                resultType:"",
                availableFlag:"",
                experimentalMethod:"",
                specimenBasicContent:"",
                specimenReviewContent:"",
                specimenType:"",
                checkTime:"",
                discountedPrice:"",
                marketPrice:"",
                price:"",
                medicineExplain:"",
                stackFlag:"",
                unit:"",
                id:"",
                precision:"",
                specimenRequest:"",
                remark:"",
                priceCode:"",
                isSpecial:"",
                projectTypeId:"",
                specimenSaveDiction:""
              },
              project:false,//配置项目穿梭模态框
              tips:false,//提示模态框
              titleProject:["未组套项目","已组套项目"],
              projectId:"",//项目id
              projecName:"",
              projectList:[],
              projectListSelected:[],
              detail:false,//组套详情模态框
              detailLoading:true,
              detailData:[],
              total:0,
              loading:true,
              page:1,
              pageSize:10,
              placement:"bottom",
              parProject:[],//父级项目
              tableData:[],
              specimenTypeArr:[],//标本类型列表
              resultTypeArr:[],//结果类型列表
              detailtCloums:[
                {
                  title: '项目代码',
                  key: 'projectCode',
                  width:120,
                  align:"center"
                },

                {
                  title: '英文名称',
                  key: 'englishName',
                  width:120,
                  align:"center"
                },
                {
                  title: '中文名称',
                  key: 'chinaName',
                  width:120,
                  align:"center"
                },
                {
                  title: '结果类型',
                  key: 'resultType',
                  width:120,
                  align:"center"
                },
                {
                  title: '是否启用',
                  key: 'availableFlag',
                  width:120,
                  align:"center"
                },

                {
                  title: '实验方法',
                  key: 'experimentalMethod',
                  width:200,
                  align:"center"
                },
                {
                  title: '标本基本量',
                  key: 'specimenBasicContent',
                  width:120,
                  align:"center"
                },
                {
                  title: '标本复查量',
                  key: 'specimenReviewContent',
                  width:120,
                  align:"center"
                },
                {
                  title: '标本类型',
                  key: 'specimenType',
                  width:120,
                  align:"center"
                },
                {
                  title: '检测时间',
                  key: 'checkTime',
                  width:120,
                  align:"center"
                },
                {
                  title: '折扣价',
                  key: 'discountedPrice',
                  width:120,
                  align:"center"
                },
                {
                  title: '市场价',
                  key: 'marketPrice',
                  width:120,
                  align:"center"
                },
                {
                  title: '价格',
                  key: 'price',
                  width:120,
                  align:"center"
                },
                {
                  title: '医学解释',
                  key: 'medicineExplain',
                  width:120,
                  align:"center"
                }
              ],
              cloums:[
                {
                  title: '项目代码',
                  key: 'projectCode',
                  width:200,
                  align:"center"
                },
                {
                  title: '物价编码',
                  key: 'priceCode',
                  width:120,
                  align:"center"
                },
                {
                  title: '英文名称',
                  key: 'englishName',
                  width:200,
                  align:"center"
                },
                {
                  title: '中文名称',
                  key: 'chinaName',
                  width:200,
                  align:"center"
                },
                {
                  title: '结果类型',
                  key: 'resultType',
                  width:200,
                  align:"center"
                },
                {
                  title: '是否启用',
                  key: 'availableFlag',
                  width:200,
                  align:"center"
                },
                {
                  title: '是否特检',
                  key: 'isSpecial',
                  width:120,
                  align:"center"
                },
                {
                  title: '实验方法',
                  key: 'experimentalMethod',
                  width:200,
                  align:"center"
                },
                {
                  title: '标本基本量',
                  key: 'specimenBasicContent',
                  width:200,
                  align:"center"
                },
                {
                  title: '标本复查量',
                  key: 'specimenReviewContent',
                  width:200,
                  align:"center"
                },
                {
                  title: '标本类型',
                  key: 'specimenType',
                  width:200,
                  align:"center"
                },
                {
                  title: '检测时间',
                  key: 'checkTime',
                  width:200,
                  align:"center"
                },
                {
                  title: '折扣价',
                  key: 'discountedPrice',
                  width:200,
                  align:"center"
                },
                {
                  title: '市场价',
                  key: 'marketPrice',
                  width:200,
                  align:"center"
                },
                {
                  title: '价格',
                  key: 'price',
                  width:200,
                  align:"center"
                },
                {
                  title: '是否组套',
                  key: 'stackFlag',
                  width:200,
                  align:"center"
                },
                {
                  title: '创建人',
                  key: 'creator',
                  width:200,
                  align:"center"
                },
                {
                  title: '修改人',
                  key: 'creator',
                  width:200,
                  align:"center"
                },
                {
                  title: '操作',
                  width:220,
                  align:"center",
                  fixed:"right",
                  render:(h,params)=>{
                    return h("div",[
                      h("Button",{
                        props:{
                          type:"primary",
                          size:"small"
                        },
                        style:{
                          marginRight:"5px"
                        },
                        on:{
                          click:()=>{
                            console.log(params.row)
                            this.edit = true;
                              this.editForm.englishName = params.row.englishName;
                              this.editForm.chinaName = params.row.chinaName;
                              for(let i in this.resultTypeArr){
                                if(this.resultTypeArr[i].dataName==params.row.resultType){
                                  this.editForm.resultType = this.resultTypeArr[i].dataCode;
                                }
                              }
                              this.editForm.availableFlag = params.row.availableFlag=="启用"?"1":"0";
                              this.editForm.experimentalMethod = params.row.experimentalMethod;
                              this.editForm.specimenBasicContent = params.row.specimenBasicContent;
                              this.editForm.specimenReviewContent = params.row.specimenReviewContent;
                              for(let i in this.specimenTypeArr){
                                if(this.specimenTypeArr[i].dataName==params.row.specimenType){
                                  this.editForm.specimenType = this.specimenTypeArr[i].dataCode;
                                }
                              }
                              this.editForm.checkTime = params.row.checkTime;
                              this.editForm.discountedPrice = params.row.discountedPrice;
                              this.editForm.marketPrice = params.row.marketPrice;
                              this.editForm.price = params.row.price;
                              this.editForm.medicineExplain = params.row.medicineExplain;
                              this.editForm.stackFlag = params.row.stackFlag=="组套"?"1":"0";
                              this.editForm.id =  params.row.id;
                              this.editForm.unit =  params.row.unit;
                              this.editForm.precision =  params.row.precision;
                              this.editForm.specimenRequest = params.row.specimenRequest;
                              this.editForm.remark = params.row.remark;
                              this.editForm.priceCode = params.row.priceCode;
                              this.editForm.isSpecial = params.row.isSpecial=="是"?"1":"0";
//                              for(let i=0;i<this.parProject.length;i++){
//                                if(this.parProject[i].proTypeName == params.row.projectTypeId){
//                                  this.editForm. projectTypeId = this.parProject[i].id;
//                                }
//                              }
                              this.editForm. projectTypeId = params.row.projectTypeId;
                              this.editForm.specimenSaveDiction = params.row.specimenSaveDiction;
                          }
                        }
                      },"编辑"),
                      h("Button",{
                        props:{
                          type:"error",
                          size:"small"
                        },
                        style:{
                          marginRight:"5px"
                        },
                        on:{
                          click:()=>{
                            console.log(params.row)
                            var _this = this;
                            _this.projectId = params.row.id;
                            _this.projecName = params.row.chinaName;
                            var qs = require("qs");
                            var param = qs.stringify({
                              projectId:_this.projectId
                            });
                            axios.post("/project/assignProject",param).then((res)=>{
                              if(res.data.code =="000000"){
                                _this.project = true;
                                _this.projectList = [];
                                _this.projectListSelected = [];
                                let unAssign = res.data.data.unAssignProjectList;//未配置组套
                                let assign = res.data.data.assignProjectList;
                                for(let i = 0;i<unAssign.length;i++){
                                  _this.projectList.push({
                                    key:unAssign[i].id,
                                    label:unAssign[i].chinaName
                                  })
                                }
                                for(let i = 0;i<assign.length;i++){
                                  _this.projectListSelected.push(assign[i].id)
                                  _this.projectList.push({
                                    key:assign[i].id,
                                    label:assign[i].chinaName
                                  })
                                }
                              }else{
                                _this.$Notice.error({title:res.data.msg});
                              }
                            })
                          }
                        }
                      },"配置组套"),
                      h("Button",{
                        props:{
                          type:"success",
                          size:"small"
                        },

                        on:{
                          click:()=>{
                            console.log(this.specimenTypeArr)
                            console.log(this.resultTypeArr)
                            var qs = require("qs");
                            var param = qs.stringify({
                              id:params.row.id
                            })
                            axios.post("/project/getStackProjectList",param).then((res)=>{
                                  if(res.data.code =="000000"){
                                    this.detailLoading = false;
                                    this.detail = true;
                                    for(let i =0;i<res.data.data.length;i++){
                                      res.data.data[i].availableFlag =  res.data.data[i].availableFlag=="1"?"启用":"未启用";
                                      for(let j=0;j<this.specimenTypeArr.length;j++){
                                        if(res.data.data[i].specimenType==this.specimenTypeArr[j].dataCode){
                                          console.log("true")
                                          res.data.data[i].specimenType = this.specimenTypeArr[j].dataName;
                                        }
                                      }
                                      for(let j=0;j<this.resultTypeArr.length;j++){
                                        if(res.data.data[i].resultType==this.resultTypeArr[j].dataCode){
                                          res.data.data[i].resultType = this.resultTypeArr[j].dataName;
                                        }
                                      }
                                    }
                                    this.detailData = res.data.data;
                                  }else{
                                    this.$Notice.error({title:res.data.msg});
                                  }
                            })

                          }
                        }
                      },"组套详情")
                    ])
                  }
                },
              ]
            }
        },
      mounted(){
        this.proInfo();
        this.init();
      },
      methods:{
        proInfo(){
          var qs = require("qs");
          var param = qs.stringify({
            dictType:"specimen_type"
          });
          var param2 = qs.stringify({
            dictType:"result_type"
          });
          axios.post("/common/dictDataList",param).then((res)=>{
            if(res.data.code =="000000"){
              this.specimenTypeArr = res.data.data;
            }else{
              this.$Notice.error({title:res.data.msg});
            }
          })
          axios.post("/common/dictDataList",param2).then((res)=>{
            if(res.data.code =="000000"){
              this.resultTypeArr= res.data.data;
            }else{
              this.$Notice.error({title:res.data.msg});
            }
          })
          //获取父级项目类型
          axios.post("projectType/selectParProjectTypeList").then((res)=>{
            console.log(res)
            if(res.data.code == "000000"){
              this.parProject = res.data.data;
            }else{
              this.$Notice.error(res.data.msg)
            }
          })
        },
        init(){
            var _this = this;
            var qs = require("qs");
            var param = qs.stringify({
              page:_this.page,
              pageSize:_this.pageSize,
              projectCode:this.formInline.projectCode,
              chinaName:this.formInline.chinaName,
              stackFlag:this.formInline.stackFlag,
              availableFlag:this.formInline.availableFlag
            });
          axios.defaults.headers.common['Authorization'] = sessionStorage.getItem("token");
          axios.post("/project/selectProjectList",param).then((res)=>{
            if(res.data.code=="000000"){
              _this.loading = false;
              _this.total = res.data.count;
                for(let i=0;i<res.data.data.length;i++){
                  res.data.data[i].stackFlag = res.data.data[i].stackFlag=="1"?"组套":"未组套";
                  res.data.data[i].availableFlag = res.data.data[i].availableFlag=="1"?"启用":"未启用";
                  res.data.data[i].isSpecial = res.data.data[i].isSpecial=="1"?"是":"否";
                    for (let j = 0; j < _this.specimenTypeArr.length; j++) {
                      if (_this.specimenTypeArr[j].dataCode == res.data.data[i].specimenType) {
                        res.data.data[i].specimenType = _this.specimenTypeArr[j].dataName;
                      }
                    }
                  for(let j = 0;j<_this.resultTypeArr.length;j++){
                    if(res.data.data[i].resultType){
                      if(_this.resultTypeArr[j].dataCode==res.data.data[i].resultType){
                        res.data.data[i].resultType =_this.resultTypeArr[j].dataName;
                      }
                    }
                  }
                }
              this.tableData = res.data.data;
            }else{
              this.$Notice.error({title:res.data.msg});
            }
          })
        },
        onSubmit(){
          this.init()
        },
        resetForm(){
          this.formInline.availableFlag = "";
          this.formInline.chinaName = "";
          this.formInline.projectCode = "";
          this.formInline.stackFlag = "";
        },
        onAdd(){
          this.add = true;
        },
        changePage(page){
          this.page = page;
          this.loading = true;
          this.init();
        },
        changeSize(size){
          this.placement = size>=20?"top":"bottom";
          this.pageSize = size;
          this.loading = true;
          this.init();
        },
        addok(){
          var qs = require("qs");
          var param=qs.stringify({
            englishName:this.addForm.englishName,
            chinaName:this.addForm.chinaName,
            resultType:this.addForm.resultType,
            availableFlag:this.addForm.availableFlag,
            experimentalMethod:this.addForm.experimentalMethod,
            specimenBasicContent:this.addForm.specimenBasicContent,
            specimenReviewContent:this.addForm.specimenReviewContent,
            specimenType:this.addForm.specimenType,
            checkTime:this.addForm.checkTime,
            discountedPrice:this.addForm.discountedPrice,
            marketPrice:this.addForm.marketPrice,
            price:this.addForm.price,
            medicineExplain:this.addForm.medicineExplain,
            stackFlag:this.addForm.stackFlag,
            specimenRequest:this.addForm.specimenRequest,
            remark:this.addForm.remark,
            priceCode:this.addForm.priceCode,
            isSpecial:this.addForm.isSpecial,
            projectTypeId:this.addForm.projectTypeId,
            specimenSaveDiction:this.addForm.specimenSaveDiction
          });
          var _this = this;
          axios.post("/project/saveProject",param).then((res)=>{
            if(res.data.code=="000000"){
              _this.$Notice.success({title:"添加成功"});
              _this.init();
            }else{
              _this.$Notice.error({title:res.data.msg});
            }
          })
        },
        editok(){
          var qs = require("qs");
          var param=qs.stringify({
            englishName:this.editForm.englishName,
            chinaName:this.editForm.chinaName,
            resultType:this.editForm.resultType,
            availableFlag:this.editForm.availableFlag,
            experimentalMethod:this.editForm.experimentalMethod,
            specimenBasicContent:this.editForm.specimenBasicContent,
            specimenReviewContent:this.editForm.specimenReviewContent,
            specimenType:this.editForm.specimenType,
            checkTime:this.editForm.checkTime,
            discountedPrice:this.editForm.discountedPrice,
            marketPrice:this.editForm.marketPrice,
            price:this.editForm.price,
            medicineExplain:this.editForm.medicineExplain,
            stackFlag:this.editForm.stackFlag,
            id:this.editForm.id,
            unit:this.editForm.unit,
            precision:this.editForm.precision,
            specimenRequest:this.editForm.specimenRequest,
            remark:this.editForm.remark,
            priceCode:this.editForm.priceCode,
            isSpecial:this.editForm.isSpecial,
            projectTypeId:this.editForm.projectTypeId,
            specimenSaveDiction:this.editForm.specimenSaveDiction
          });
          var _this = this;
          axios.post("/project/updateProject",param).then((res)=>{
            if(res.data.code=="000000"){
              _this.$Notice.success({title:"修改成功"});
              _this.init();
            }else{
              _this.$Notice.error({title:res.data.msg});
            }
          })
        },
        handleChange2 (newTargetKeys) {
          console.log(newTargetKeys);
          this.projectListSelected = newTargetKeys;
        },
        filterMethod (data, query) {
          return data.label.indexOf(query) > -1;
        },
        projectok(){
          this.tips = true;
        },
        tipsok(){
            var qs = require("qs");
            var param = qs.stringify({
              projectId:this.projectId,
              chinaName:this.projecName,
              stackIdStr:this.projectListSelected.join(",")
            });
            axios.post("/project/saveStackProject",param).then((res)=>{
                if(res.data.code == "000000"){
                  this.$Notice.success({title:"配置成功!"});
                  this.init();
                }else{
                  this.$Notice.error({title:res.data.msg});
                }
            })
        },
         cancel (msg) {
          this.$Notice.info({title:msg});
        },
      }
    }
</script>
